@import '../../style/themes/default';
@import '../../style/mixins/index';
@import '../../input/style/mixin';

@cascader-prefix-cls: ~'@{c7n-prefix}-cascader';

.@{cascader-prefix-cls} {
  .reset-component;

  &-input.@{c7n-prefix}-input {
    display: block;
    width: 100%;
    // because input.less will compile after cascader.less
    background-color: transparent !important;
    cursor: pointer;
  }

  &-picker {
    .reset-component;
    position: relative;
    display: inline-block;
    background-color: @component-background;
    border-radius: @border-radius-base;
    outline: 0;
    cursor: pointer;

    & .@{c7n-prefix}-input-rendered {
      margin: 0;
    }
    &-with-value &-label {
      color: transparent;
    }

    &-disabled {
      color: @disabled-color;
      background: @input-disabled-bg;
      cursor: not-allowed;
      .@{cascader-prefix-cls}-input {
        cursor: not-allowed;
      }
    }

    &:focus .@{cascader-prefix-cls}-input {
      .active;
    }

    &-label {
      position: absolute;
      top: 50%;
      left: 0;
      width: 100%;
      margin-top: -0.1rem;
      padding: @input-padding-vertical-base @input-padding-horizontal;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
    }

    .@{c7n-prefix}-input-has-label .@{c7n-prefix}-input-content {
      padding-top: 0;
    }

    &-clear {
      position: absolute;
      top: 50%;
      right: .01rem;
      z-index: 2;
      width: 0.2rem;
      height: 0.2rem;
      margin-top: -0.08rem;
      color: @input-color;
      background: @component-background;
      cursor: pointer;
      opacity: 0;
      transition: color 0.3s ease, opacity 0.15s ease;
    }

    &:hover &-clear {
      opacity: 1;
    }

    // arrow
    &-arrow {
      position: absolute;
      top: 50%;
      right: .01rem;
      z-index: 1;
      width: 0.2rem;
      height: 0.2rem;
      margin-top: -0.08rem;
      color: @input-color;
      &::before {
        transition: transform 0.2s;
      }
      &&-expand {
        &::before {
          transform: rotate(180deg);
        }
      }
    }
  }

  &-picker-small &-picker-clear,
  &-picker-small &-picker-arrow {
    right: 0;
  }

  &-menus {
    position: absolute;
    z-index: @zindex-dropdown;
    font-size: @font-size-base;
    white-space: nowrap;
    background: @component-background;
    border-radius: @border-radius-base;
    box-shadow: @shadow-4;

    ul,
    ol {
      margin: 0;
      padding: 0;
      list-style: none;
    }

    &-empty,
    &-hidden {
      display: none;
    }
    &.slide-up-enter.slide-up-enter-active&-placement-bottomLeft,
    &.slide-up-appear.slide-up-appear-active&-placement-bottomLeft {
      animation-name: antSlideUpIn;
    }

    &.slide-up-enter.slide-up-enter-active&-placement-topLeft,
    &.slide-up-appear.slide-up-appear-active&-placement-topLeft {
      animation-name: antSlideDownIn;
    }

    &.slide-up-leave.slide-up-leave-active&-placement-bottomLeft {
      animation-name: antSlideUpOut;
    }

    &.slide-up-leave.slide-up-leave-active&-placement-topLeft {
      animation-name: antSlideDownOut;
    }
  }
  &-menu {
    display: inline-block;
    min-width: 1.11rem;
    height: 1.8rem;
    margin: 0;
    padding: 0;
    overflow: auto;
    vertical-align: top;
    list-style: none;
    border-right: @border-width-base @border-style-base @border-color-split;
    &:first-child {
      border-radius: @border-radius-base 0 0 @border-radius-base;
    }
    &:last-child {
      margin-right: -0.01rem;
      border-right-color: transparent;
      border-radius: 0 @border-radius-base @border-radius-base 0;
    }
    &:only-child {
      border-radius: @border-radius-base;
    }
    &-single {
      border-right: 0;
      &:last-child {
        margin-right: 0;
      }
    }
    &-single &-item {
      float: left;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    &-tab {
      margin-top: .05rem;
      margin-bottom: .1rem;
      padding: 0.08rem 0.19rem 0.04rem 0;
      font-size: 0.12rem;
      border-bottom: 0.015rem solid @primary-color;

      &-item {
        height: 0.2rem;
        margin-left: 0.08rem;
        padding: 0.06rem 0.02rem 0.06rem @control-padding-horizontal;
        color: @text-color;
        font-weight: 500;
        font-size: 0.13rem;
        line-height: 0.2rem;
        white-space: nowrap;
        vertical-align: middle;
        border-top: 0.01rem solid @border-color-base;
        border-right: 0.01rem solid @border-color-base;
        border-left: 0.01rem solid @border-color-base;
        border-top-left-radius: 0.05rem;
        border-top-right-radius: 0.05rem;
        cursor: pointer;

        &:hover {
          border-color: initial;
        }

        &:last-child {
          position: relative;
          color: @primary-color;
          border-top: 0.015rem solid @primary-color;
          border-right: 0.015rem solid @primary-color;
          border-left: 0.015rem solid @primary-color;

          &::after {
            position: absolute;
            bottom: -0.03rem;
            left: 0;
            width: 100%;
            height: 0.04rem;
            color: @primary-color;
            background-color: white;
            content: ' ';
          }
        }
      }
      &-please{
        cursor: text;
        &:hover {
          background: none;
        }
      }
    }
  }
  &-menu-item {
    padding: 0.05rem @control-padding-horizontal;
    line-height: 0.22rem;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.3s;
    &:hover {
      background: @item-hover-bg;
    }
    &-disabled {
      color: @disabled-color;
      cursor: not-allowed;
      &:hover {
        background: transparent;
      }
    }
    &-active:not(&-disabled) {
      &,
      &:hover {
        font-weight: 600;
        background: @background-color-base;
      }
    }
    &-expand {
      position: relative;
      padding-right: 24px;
      &-icon {
        position: absolute;
        right: @control-padding-horizontal;
        color: @text-color-secondary;
      }
    }
    &-loading::after {
      .iconfont-font('\e64d');
      animation: loadingCircle 1s infinite linear;
    }

    & &-keyword {
      color: @highlight-color;
    }
  }
}
